<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<style>
			.active {
				width: 100px;
				height: 100px;
				border: 1px solid red;
			}
			.bgc {
				background-color: lime;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<!-- <div class="active">样式处理</div> -->

			<!-- 对象形式绑定类名，键是类名，值是布尔值，控制类是否显示 -->
			<div :class="{ active: isActive,bgc: isActive }">对象样式处理</div>
			<button @click="handle">切换样式</button>

			<!-- 数组绑定类名，不能够直接写类名 -->
			<!-- 数组形式绑定类名，需要在 data 中以键值形式进行声明，键是自定义属性，值是class类名 -->
			<div :class="[ activeClass, bgcClass ]">数组样式处理</div>
			<!-- <button @click="handle1">切换样式</button> -->
		</div>

		<script src="/scripts/vue.js"></script>
		<script>
			var vm = new Vue({
				el: '#app',
				data: {
					isActive: true,
					activeClass: 'active',
					bgcClass: 'bgc',
				},
				methods: {
					handle() {
						this.isActive = !this.isActive
					},
				},
			})
		</script>
	</body>
</html>
